/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Modelo;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author ChArFaTo
 */
@Entity
@Table(name = "persona", catalog = "proyectosw", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "PersonaEJB.findAll", query = "SELECT p FROM PersonaEJB p"),
    @NamedQuery(name = "PersonaEJB.findByPIdentificacion", query = "SELECT p FROM PersonaEJB p WHERE p.pIdentificacion = :pIdentificacion"),
    @NamedQuery(name = "PersonaEJB.findByPNombres", query = "SELECT p FROM PersonaEJB p WHERE p.pNombres = :pNombres"),
    @NamedQuery(name = "PersonaEJB.findByPApellidos", query = "SELECT p FROM PersonaEJB p WHERE p.pApellidos = :pApellidos"),
    @NamedQuery(name = "PersonaEJB.findByPGenero", query = "SELECT p FROM PersonaEJB p WHERE p.pGenero = :pGenero"),
    @NamedQuery(name = "PersonaEJB.findByPTelefono", query = "SELECT p FROM PersonaEJB p WHERE p.pTelefono = :pTelefono"),
    @NamedQuery(name = "PersonaEJB.findByPTipoDocumento", query = "SELECT p FROM PersonaEJB p WHERE p.pTipoDocumento = :pTipoDocumento")})
public class PersonaEJB implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(nullable = false)
    private Long pIdentificacion;
    @Size(max = 255)
    @Column(length = 255)
    private String pNombres;
    @Size(max = 255)
    @Column(length = 255)
    private String pApellidos;
    @Size(max = 255)
    @Column(length = 255)
    private String pGenero;
    @Basic(optional = false)
    @NotNull
    @Column(nullable = false)
    private long pTelefono;
    @Size(max = 255)
    @Column(length = 255)
    private String pTipoDocumento;
    @OneToMany(mappedBy = "personaPIdentificacion")
    private Collection<EstudianteEJB> estudianteEJBCollection;
    @OneToMany(mappedBy = "personaPIdentificacion")
    private Collection<JefeDeProgramaEJB> jefeDeProgramaEJBCollection;
    @OneToMany(mappedBy = "personaPIdentificacion")
    private Collection<DocenteEJB> docenteEJBCollection;
    @JoinColumn(name = "UsuarioUId", referencedColumnName = "UId")
    @ManyToOne
    private UsuarioEJB usuarioUId;

    public PersonaEJB() {
    }

    public PersonaEJB(Long pIdentificacion) {
        this.pIdentificacion = pIdentificacion;
    }

    public PersonaEJB(Long pIdentificacion, long pTelefono) {
        this.pIdentificacion = pIdentificacion;
        this.pTelefono = pTelefono;
    }

    public Long getPIdentificacion() {
        return pIdentificacion;
    }

    public void setPIdentificacion(Long pIdentificacion) {
        this.pIdentificacion = pIdentificacion;
    }

    public String getPNombres() {
        return pNombres;
    }

    public void setPNombres(String pNombres) {
        this.pNombres = pNombres;
    }

    public String getPApellidos() {
        return pApellidos;
    }

    public void setPApellidos(String pApellidos) {
        this.pApellidos = pApellidos;
    }

    public String getPGenero() {
        return pGenero;
    }

    public void setPGenero(String pGenero) {
        this.pGenero = pGenero;
    }

    public long getPTelefono() {
        return pTelefono;
    }

    public void setPTelefono(long pTelefono) {
        this.pTelefono = pTelefono;
    }

    public String getPTipoDocumento() {
        return pTipoDocumento;
    }

    public void setPTipoDocumento(String pTipoDocumento) {
        this.pTipoDocumento = pTipoDocumento;
    }

    @XmlTransient
    public Collection<EstudianteEJB> getEstudianteEJBCollection() {
        return estudianteEJBCollection;
    }

    public void setEstudianteEJBCollection(Collection<EstudianteEJB> estudianteEJBCollection) {
        this.estudianteEJBCollection = estudianteEJBCollection;
    }

    @XmlTransient
    public Collection<JefeDeProgramaEJB> getJefeDeProgramaEJBCollection() {
        return jefeDeProgramaEJBCollection;
    }

    public void setJefeDeProgramaEJBCollection(Collection<JefeDeProgramaEJB> jefeDeProgramaEJBCollection) {
        this.jefeDeProgramaEJBCollection = jefeDeProgramaEJBCollection;
    }

    @XmlTransient
    public Collection<DocenteEJB> getDocenteEJBCollection() {
        return docenteEJBCollection;
    }

    public void setDocenteEJBCollection(Collection<DocenteEJB> docenteEJBCollection) {
        this.docenteEJBCollection = docenteEJBCollection;
    }

    public UsuarioEJB getUsuarioUId() {
        return usuarioUId;
    }

    public void setUsuarioUId(UsuarioEJB usuarioUId) {
        this.usuarioUId = usuarioUId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pIdentificacion != null ? pIdentificacion.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PersonaEJB)) {
            return false;
        }
        PersonaEJB other = (PersonaEJB) object;
        if ((this.pIdentificacion == null && other.pIdentificacion != null) || (this.pIdentificacion != null && !this.pIdentificacion.equals(other.pIdentificacion))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Modelo.PersonaEJB[ pIdentificacion=" + pIdentificacion + " ]";
    }
    
}
